//
//  WYMyClueController.m
//  CirclePush
//
//  Created by admin on 2018/4/19.
//  Copyright © 2018年 admin. All rights reserved.
//

#import "WYMyClueController.h"
#import "WYAllClueController.h"
@interface WYMyClueController ()<SGPageTitleViewDelegate, SGPageContentViewDelegate>
@property (nonatomic, strong) SGPageTitleView *pageTitleView;
@property (nonatomic, strong) SGPageContentView *pageContentView;
@end

@implementation WYMyClueController

- (void)viewDidLoad {
    [super viewDidLoad];
    [self setupUI];
    // Do any additional setup after loading the view.
}
-(void)setupUI
{
    [self initTopBarWithTitle:@"我的线索"];
    [self addLeftButton:[UIImage imageNamed:@"return"] width:0 height:0];
    
    CGFloat statusHeight = CGRectGetHeight([UIApplication sharedApplication].statusBarFrame);
    CGFloat pageTitleViewY = 0;
    if (statusHeight == 20.0) {
        pageTitleViewY = 64;
    } else {
        pageTitleViewY = 88;
    }
    NSArray *titleArr = @[@"全部", @"进行中", @"已完成", @"已关闭"];
    SGPageTitleViewConfigure *configure = [SGPageTitleViewConfigure pageTitleViewConfigure];
    configure.indicatorAdditionalWidth = 10; // 说明：指示器额外增加的宽度，不设置，指示器宽度为标题文字宽度；若设置无限大，则指示器宽度为按钮宽度
    
    /// pageTitleView
    self.pageTitleView = [SGPageTitleView pageTitleViewWithFrame:CGRectMake(0, pageTitleViewY, self.view.frame.size.width, 44) delegate:self titleNames:titleArr configure:configure];
    [self.view addSubview:_pageTitleView];
    
     WYAllClueController *aVc = [[WYAllClueController alloc]init];
     aVc.type = @"";
    
     WYAllClueController *aVc1 = [[WYAllClueController alloc]init];
     aVc1.type = @"3";
    
     WYAllClueController *aVc2 = [[WYAllClueController alloc]init];
     aVc2.type = @"4";
    
     WYAllClueController *aVc3 = [[WYAllClueController alloc]init];
     aVc3.type = @"5";
    
    NSArray *childArr =@[aVc,aVc1,aVc2,aVc3];
    CGFloat contentViewHeight = self.view.frame.size.height - CGRectGetMaxY(_pageTitleView.frame);
    self.pageContentView = [[SGPageContentView alloc] initWithFrame:CGRectMake(0, CGRectGetMaxY(_pageTitleView.frame), self.view.frame.size.width, contentViewHeight) parentVC:self childVCs:childArr];
    _pageContentView.delegatePageContentView = self;
    [self.view addSubview:_pageContentView];
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}


//- (void)pageContentView:(SGPageContentView *)pageContentView progress:(CGFloat)progress originalIndex:(NSInteger)originalIndex targetIndex:(NSInteger)targetIndex;
///**
// *  给 SGPageContentView 所在控制器提供的方法（根据偏移量来处理返回手势的问题）
// *
// *  @param pageContentView     SGPageContentView
// *  @param offsetX             SGPageContentView 内部视图的偏移量
// */
//- (void)pageContentView:(SGPageContentView *)pageContentView offsetX:(CGFloat)offsetX;


- (void)pageTitleView:(SGPageTitleView *)pageTitleView selectedIndex:(NSInteger)selectedIndex {
//    [self.pageContentView setPageCententViewCurrentIndex:selectedIndex];
    [self.pageContentView setPageContentViewCurrentIndex:selectedIndex];
    
}
- (void)pageContentView:(SGPageContentView *)pageContentView progress:(CGFloat)progress originalIndex:(NSInteger)originalIndex targetIndex:(NSInteger)targetIndex {
    [self.pageTitleView setPageTitleViewWithProgress:progress originalIndex:originalIndex targetIndex:targetIndex];
}
@end
